package br.uefs.dexa.rfframework.gui.utils.paging;

import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.BorderFactory;



public class PreviousLabel extends PagingLabel {

	
	private static final long serialVersionUID = 7125091953717934681L;
	
	private PagingOutputObjectSetContainerPanel pagingPanel;
	
	
	protected PreviousLabel(PagingOutputObjectSetContainerPanel pagingPanel)
	{
		super(0 , pagingPanel);
		this.pagingPanel = pagingPanel; 
		//setText("Prev");
		setText("<");
		
		Font f = getFont();
		setFont(f.deriveFont(f.getStyle() | Font.BOLD));
		
	}

	@Override
	protected void addMouseListener()
	{
		addMouseListener( new MouseAdapter() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseExited(MouseEvent e) {
				
//				if(!isCurrentPage()) {
//					reset();
//				} else {
//					markAsCurrentPage();					
//				}
				
				reset();
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
				setBorder(BorderFactory.createLineBorder(MOUSE_HOVER_COLOR, BORDER_THICKNESS));
				setForeground(MOUSE_HOVER_COLOR);	
			}
			
			@Override
			public void mouseClicked(MouseEvent e) 
			{	
				//pagingPanel.setLimits(page);
				pagingPanel.previousPage();
				
				Thread t = new Thread( new Runnable() {
					@Override
					public void run() {
						pagingPanel.showPage();
						
					}
				});
				t.start();
				
				pagingPanel.resetLabels();
				pagingPanel.markCurrentPage();
				//markAsCurrentPage();
			}
		});
	}
	
	
	
	
	

}
